#!/bin/sh

#Definition des variables globales
install_path=$(pwd);
logpp_path="/usr/local/bin/logpp";
sec_path="/usr/local/bin/sec";
python_path="/usr/bin/python";
perl_path="/usr/bin/perl";
error=0;

echo "#############################";
echo "script d'installation de fiem";
echo "#############################";


echo "+ Configuration de l'environnement";

echo "+ Verification des prerequis";

if [ -x $logpp_path ]; 
then 
    echo "logpp: OK";
else 
    echo "- logpp: inexistant";
    echo "+ logpp: installation du binaire";
    echo "+ logpp: acces au dossier d'installation";		
    cd $install_path"/logpp";
    ./configure

if test $? -eq 0
    then
        make;
        make install;
        cd $install_path;
    else
        echo "- logpp: erreur d'installation";
        $error=1;
    fi
fi	

if [ -x $perl_path ];
    then 
        echo "+ perl: OK";
    else 
        echo "- perl: KO"; 
        $error=1;
fi

if [ -x $sec_path ];
then 
    echo "+ sec: OK";
else
    echo "- sec: inexistant";
    echo "+ sec: acces au dossier d'installation";		
    cd $install_path"/sec";
    cp sec $sec_path;
    cp sec.man /usr/local/man/man1/sec.1;
    if test $? -ne 0
    then
        $error=1;
    fi
fi

if [ -x $python_path ]; 
then 
echo "+ python: OK"; 
else
echo "- python: KO"; 
$error=1;
fi



if test $error -eq 0
then
	echo "+ Installation de FIEM";
else
	echo "- ERREUR";
fi

